FROM node:12.19.1-alpine3.12 AS builder

ARG CMD
ARG VUE_APP_IS_SAAS=false
ARG VUE_APP_PRODUCT_MODEL=standard
ARG VUE_APP_BASE_API=/api
ARG VUE_APP_PUBLIC_PATH=/
ARG VUE_APP_WXIMG_URL
ARG VUE_APP_WXAUTHCALL_Url=/
ARG VUE_APP_PREFIXES
ARG VUE_APP_QIANKUN_ENTRY=/newpc/
ARG VUE_APP_FREE
ARG VUE_APP_OSS_CDN
ARG VUE_APP_QINIU_ACCESS_KEY
ARG VUE_APP_QINIU_SECRET_KEY
ARG VUE_APP_QINIU_BUCKET
ARG VUE_APP_QINIU_PATH

ENV VUE_APP_IS_SAAS ${VUE_APP_IS_SAAS}
ENV VUE_APP_PRODUCT_MODEL ${VUE_APP_PRODUCT_MODEL}
ENV VUE_APP_BASE_API ${VUE_APP_BASE_API}
ENV VUE_APP_PUBLIC_PATH ${VUE_APP_PUBLIC_PATH}
ENV VUE_APP_WXIMG_URL ${VUE_APP_WXIMG_URL}
ENV VUE_APP_WXAUTHCALL_Url ${VUE_APP_WXAUTHCALL_Url}
ENV VUE_APP_PREFIXES ${VUE_APP_PREFIXES}
ENV VUE_APP_QIANKUN_ENTRY ${VUE_APP_QIANKUN_ENTRY}
ENV VUE_APP_FREE ${VUE_APP_FREE}
ENV VUE_APP_OSS_CDN ${VUE_APP_OSS_CDN}
ENV VUE_APP_QINIU_ACCESS_KEY ${VUE_APP_QINIU_ACCESS_KEY}
ENV VUE_APP_QINIU_SECRET_KEY ${VUE_APP_QINIU_SECRET_KEY}
ENV VUE_APP_QINIU_BUCKET ${VUE_APP_QINIU_BUCKET}
ENV VUE_APP_QINIU_PATH ${VUE_APP_QINIU_PATH}

WORKDIR /app
COPY package*.json ./
RUN npm config set registry https://registry.npmmirror.com && npm config set @shopex:registry http://registry.npm.ishopex.cn && npm ci

COPY . .
COPY .env ./
COPY .env.* ./
RUN ls -la
RUN ${CMD}
RUN ls -l /app/dist

FROM registry.cn-zhangjiakou.aliyuncs.com/jst-shopex/openresty:1.19
WORKDIR /app
COPY --from=builder /app/dist .
EXPOSE 80
# CMD ["nginx"]
